// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
// import AMap from 'amap'
import App from './App'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import '@/permission' // 权限
import '@/components/icons'
import waves from '@/directive/waves'
import CONST from './const'
import filters from '@/filters'
import '@/mock'

Vue.config.productionTip = process.env.NODE_ENV !== 'development'
Vue.config.devtools = process.env.NODE_ENV === 'development'
Vue.config.performance = process.env.NODE_ENV === 'development'

Vue.prototype.$DEBUG = process.env.NODE_ENV === 'development'

Vue.prototype.$BASE_API = process.env.VUE_APP_BASE_API

Vue.prototype.$SOURCE_ID = process.env.VUE_APP_SOURCE_ID
// 应用名字
Vue.prototype.$APP_NAME = process.env.VUE_APP_NAME || '管理平台'

Vue.prototype.$CONST = CONST

Vue.prototype.$EventBus = new Vue()

Vue.directive('waves', waves)

/**
 * 注册全局filters
 */
Object.keys(filters).forEach(name => {
  Vue.filter(name, filters[name])
})

/**
 * 注册全局组件
 */
// const requireComponent = require.context('./components', true, /\.vue$/)
// requireComponent.keys().filter(f => f.includes('device/')).forEach(fileName => {
//   const componentConfig = requireComponent(fileName)
//   const componentName = fileName.split('/').pop().replace(/\.\w+$/, '').toUpperCase()
//   Vue.component(componentName, componentConfig.default || componentConfig)
// })

/**
 * 计算列表布局容器的高度
 */
Vue.prototype.computeListLayoutContainerSize = function () {
  document.getElementsByClassName('el-container')[0].style.height = window.innerHeight + 'px'
}

/**
 * 绑定window的size变动事件
 */
Vue.prototype.bindSizeChange = function () {
  var $this = this
  window.onresize = function () {
    $this.computeListLayoutContainerSize()
  }
}

Vue.use(ElementUI, {
  size: 'mini'
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
